package com.dog.basics.admin.controller.mtkj;


import com.baomidou.mybatisplus.core.metadata.IPage;
import com.dog.basics.bean.dto.admin.mtkj.OrderEditDto;
import com.dog.basics.bean.dto.admin.mtkj.OrderFromDto;
import com.dog.basics.bean.vo.admin.mtkj.OrderVo;
import com.dog.basics.common.annotation.SysLog;
import com.dog.basics.common.util.PageParam;
import com.dog.basics.common.util.R;
import com.dog.basics.service.mtkj.IMtDeviceOrderService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 * 设备订单 前端控制器
 * </p>
 *
 * @author wph
 * @since 2020-09-29
 */
@RestController
@RequestMapping("/pc/device/order")
@Api(value = "设备订单模块", tags = "设备订单模块")
@AllArgsConstructor
public class MtDeviceOrderController {
    private final IMtDeviceOrderService mtDeviceOrderService;
    /**
     * @Description: 设备订单列表
     * @Param: OrderFromDto
     * @return: IPage<OrderVo>
     * @Author: wph
     * @Date:
     */

    @ApiOperation(value = "设备订单列表", notes = "pc:mtDeviceOrder:page")
    @GetMapping("/page")
    @PreAuthorize("@pms.hasPermission('pc:mtDeviceOrder:page')")
    public R<IPage<OrderVo>> page(PageParam page, OrderFromDto obj) {
        return R.ok(mtDeviceOrderService.getPageList(page, obj));
    }
    /**
     * @Description: 关闭订单
     * @Param: OrderFromDto
     * @return: IPage<OrderVo>
     * @Author: wph
     * @Date:
     */
    @SysLog("关闭订单")
    @ApiOperation(value = "关闭订单", notes = "pc:mtDeviceOrder:closeOrder")
    @ApiImplicitParam(value = "订单Id", name = "id", dataType = "Long", required = true)
    @PutMapping("/closeOrder/{id}")
    @PreAuthorize("@pms.hasPermission('pc:mtDeviceOrder:closeOrder')")
    public R<Boolean> closeOrder(@PathVariable("id") Long id) {
        return R.ok(mtDeviceOrderService.closeOrder(id));
    }
    /**
     * @Description: 结束订单
     * @Param: OrderFromDto
     * @return: IPage<OrderVo>
     * @Author: wph
     * @Date:
     */
    @SysLog("结束订单")
    @ApiOperation(value = "结束订单", notes = "pc:mtDeviceOrder:endOrder")
    @ApiImplicitParam(value = "订单Id", name = "id", dataType = "Long", required = true)
    @PutMapping("/endOrder/{id}")
    @PreAuthorize("@pms.hasPermission('pc:mtDeviceOrder:endOrder')")
    public R<Boolean> endOrder(@PathVariable("id") Long id) {
        return R.ok(mtDeviceOrderService.endOrder(id));
    }

    /**
     * @Description: 修改订单金额
     * @Param: OrderFromDto
     * @return: IPage<OrderVo>
     * @Author: wph
     * @Date:
     */
    @SysLog("修改订单金额")
    @ApiOperation(value = "修改订单金额", notes = "pc:mtDeviceOrder:page")
    @PutMapping("/edit")
    @PreAuthorize("@pms.hasPermission('pc:mtDeviceOrder:page')")
    public R<Boolean> edit(OrderEditDto obj) {
        return R.ok(mtDeviceOrderService.editObj(obj));
    }
    /**
     * @Description: 确认退款
     * @Param: ids
     * @return: Boolean
     * @Author: wph
     * @Date: 2020/05/19  0027
     */
    @SysLog("确认退款")
    @ApiOperation(value = "确认退款", notes = "pc:mtDeviceOrder:return")
    @ApiImplicitParam(value = "订单Id", name = "id", dataType = "Long", required = true)
    @PutMapping("/returnObj/{id}")
    @PreAuthorize("@pms.hasPermission('pc:mtDeviceOrder:return')")
    public R editOrderInfoFund(@PathVariable("id") Long id) {
        return R.ok(mtDeviceOrderService.pcReturnObj(id));
    }

}
